﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

// 音乐管理
public class SoundMgr : Singleton<SoundMgr>
{
    // 场景中加一个音乐，n秒后销毁
    public void AddSceneSoundEffect(string path, Vector3 pos, float duringTime = 0.5f)
    {
        GameObject go = new GameObject("soundEffect");
        GameObject.Destroy(go, duringTime);

        var audio = go.AddComponent<AudioSource>();
        audio.clip = ResMgr.Instance.LoadTemplate<AudioClip>(path);
        audio.playOnAwake = false;
        audio.Play();
    }
}
